# 6_1 屏幕使用：屏幕基础配置
# https://learn.adafruit.com/circuitpython-display-support-using-displayio
# https://learn.adafruit.com/circuitpython-display-support-using-displayio/ui-quickstart
# https://learn.adafruit.com/custom-fonts-for-pyportal-circuitpython-display

'''
1. 屏幕基础配置
'''
import board
import digitalio
import displayio
from adafruit_st7789 import ST7789

# 1. 屏幕基础配置
# 默认屏幕
# board.DISPLAY

# 释放显示屏
displayio.release_displays()

# 屏幕电源
tft_power = digitalio.DigitalInOut(board.TFT_I2C_POWER)
tft_power.switch_to_output()
# 屏幕背光
tft_bl = digitalio.DigitalInOut(board.TFT_BACKLIGHT)
tft_bl.switch_to_output()

tft_power.value = True
tft_bl.value = True

# 初始化屏幕
spi = board.SPI()
display_bus = displayio.FourWire(spi, command=board.TFT_DC, chip_select=board.TFT_CS)
display = ST7789(
    display_bus, rotation=270, width=240, height=135, rowstart=40, colstart=53
)
